import java.util.Scanner;
import  java.math.*;
public class Main3 {
    static class Date{
        int year;
        int month;
        int day;
        int det;

        public Date(int year, int month, int day) {
            this.year = year;
            this.month = month;
            this.day = day;
            if((year%4==0&&year%100!=0)||year%400==0){
                this.det=1;
            }
            else
                this.det=0;
        }

        public void  days(){
            int sum=0;
            switch (month-1){
                case 11 :sum+=30;
                case 10 :sum+=31;
                case 9 :sum+=30;
                case 8 :sum+=31;
                case 7 :sum+=31;
                case 6 :sum+=30;
                case 5 :sum+=31;
                case 4 :sum+=30;
                case 3 :sum+=31;
                case 2 :sum+=det==1?29:28;
                case 1 :sum+=31;
                default:sum+=this.day;
            }
            System.out.println(sum);
        }
    }

    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int year=scanner.nextInt();
        int month=scanner.nextInt();
        int day=scanner.nextInt();
        Date date=new Date(year,month,day);
        date.days();
    }


}